package test;
import java.util.Arrays;
import java.util.Comparator;
class Bookss {
    private String title;
    private double price;
    public Bookss(String title, double price) {
        this.title = title;
        this.price = price;
    }
    // 修正方法名，首字母大写
    public String toString() {
        return "【Book】图书名称：" + this.title + "、图书价格：" + this.price + "\n";
    }
    // 添加getPrice方法，用于获取价格
    public double getPrice() {
        return price;
    }
    // setter方法、getter方法、无参构造方法略
}
public class YootkDemo12 {
    public static void main(String[] args) throws Exception {
        Bookss[] books = new Bookss[]{new Bookss("《Java Web开发》", 68.8),
                new Bookss("《C语言程序设计》", 48.8),
                new Bookss("《C#语言程序设计》", 68.8)};
        Comparator<Bookss> comparator = (o1, o2) -> {
            // 修正比较逻辑，比较o1和o2的价格
            if (o1.getPrice() > o2.getPrice()) {
                return 1;
            } else if (o1.getPrice() < o2.getPrice()) {
                return -1;
            } else {
                return 0;
            }
        };
        Arrays.sort(books, comparator);
        System.out.println(Arrays.toString(books));
    }
}